<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>测试websocket</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/socket.io/4.7.5/socket.io.js"></script>
</head>
<body>
<script>
    var websocketins=null
    function initWebSocket(){
        websocketins=io.connect('ws://127.0.0.1:8001/aigc',{
            transports: ['websocket'],
            timeout:300000,
            reconnectionDelayMax: 1000,
            reconnectionDelay: 500
        })
       websocketins.on('connect', () => {
            console.log('建立链接')
            websocketins.emit('message', {'msg': '客户端建立连接'});
        })
        websocketins.on('message', (msg) => {
            console.log("message:",msg)
        })
        websocketins.on('disconnect', () => {
                console.log('连接断开')
                websocketins.emit('message', { 'msg': '客户端断开连接' });
        })
    }
    initWebSocket()
</script>
</body>
</html>